#include "dlgmain.h"
#include <QApplication>
#include <Ice/Ice.h>
#include <thread>
#include "dlgmain.h"

DlgMain* pDlgMain = NULL;

class Server : public Ice::Application
{
public:
    Server(QCoreApplication* p){
        m_pApp = p;
    }
    virtual int run(int argc, char* argv[]){

        communicator()->waitForShutdown();

        QCoreApplication::processEvents();
        if(pDlgMain){
            pDlgMain->on_btn_exit_clicked();
        }
        m_pApp->exit();
        return 0;
    }
private:
    QCoreApplication* m_pApp;

};

void t_run(QCoreApplication* p){
    Server app(p);
    app.main(__argc, __argv);
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    pDlgMain = new DlgMain();
    //pDlgMain->show();

    std::thread t1(t_run, &a);
    t1.detach();
    return a.exec();
}

